// TrialMapper.java
package com.example.elysiumease.mapper;

import com.example.elysiumease.model.TrialRecord;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TrialMapper {
    @Insert("INSERT INTO trials (soul_id, judge_id, start_time, status) " +
            "VALUES (#{soulId}, #{judgeId}, #{startTime}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "trialId")
    int insert(TrialRecord record);

    @Update("UPDATE trials SET end_time=#{endTime}, status=#{status}, " +
            "verdict_details=#{verdictDetails}, sentence_duration=#{sentenceDuration}, " +
            "punishment_type=#{punishmentType} WHERE trial_id=#{trialId}")
    int update(TrialRecord record);

    @Select("SELECT * FROM trials WHERE trial_id = #{trialId}")
    TrialRecord selectById(Long trialId);

    @Select("SELECT * FROM trials WHERE soul_id = #{soulId} ORDER BY start_time DESC")
    List<TrialRecord> selectBySoulId(Integer soulId);
}